
function get_pizza_calculate(){
  $.ajax({
    type: "POST",
    url:  'ajax.php?function=calculate-pizza-feasts-builder&t='  + new Date().getTime(),
    data:  $('#pizzaform').serialize(),
    success: function(msg){
      if(msg == 'error'){
        $(".topping").attr('disabled',true);
      } else {				  
        $(".topping").attr('disabled',false); 
        $('#pizza_price').html(msg);
      }
    }
  });		
}

$(function() {

  var lang = window.rbiller.lang.pizzabuilder; 

  $( "#pizza-tabs" ).tabs();
  get_pizza_calculate();

  //calculate totals
  $('.calc').bind('click', function() {
    get_pizza_calculate();
  });
		
  $('.add-pizza').bind('click', function() {
    $.ajax({
      type: "POST",
      url:  'ajax.php?function=calculate-pizza-feasts-builder&add=1&t='  + new Date().getTime(),
      data:  $('#pizzaform').serialize(),
      success: function(msg){
        $('#pizza_price').html(msg);
      }
    });	
                  
    $('.popup').html("<p>" + lang.pizza_added + "</p>");

    var buttons = {};
    buttons[lang.checkout_button] = function() {
      $( this ).dialog( "close" );
      window.location = "index.php?act=checkout"
    };

    buttons[lang.continue_button] = function() {
      //$( this ).dialog( "close" );
      location.reload(true);
    
    };

    $( '.popup' ).dialog({
      width: 400,
      height: 200,
      modal: true,
      buttons: buttons 
    });		
    return false;
  });
  
});
	
	
	
	
	
	
	
	
